//
// Created by Alex on 2021/12/1.
//
#include "GeoLayer.h"
#include <QVariant>
#include <QDebug>
#define mout qDebug() <<"["<<__FILE__<<":"<<__LINE__<<"]"

GeoLayer::GeoLayer() {

}

void GeoLayer::addObject(GeoObject *obj) {
    this->objs.append(obj);
}

void GeoLayer::addProperties(QString key, QVariant value){
    this->properties.insert(key,value);
}

GeoObject* GeoLayer::getObjByProperty(QString key, QString value) {

    for(int i = 0;i < objs.count();i++) {
        if (objs.at(i)->getPropertiesValue(key).toString() == value)
            return objs.at(i);
    }
    return nullptr;
}


QVariant GeoLayer::getPropertiesValue(QString key) {
    if(properties.contains(key))
    {
        return properties.value(key);
    }else{
        return "NULL";
    }
}

int GeoLayer::getObjSize()
{
    return this->objs.size();
}

GeoObject *GeoLayer::getObject(int index)
{
    return this->objs.at(index);
}
